package cn.zs.supply.common.core.service;

import cn.zs.supply.common.core.domain.dto.LoginUserDto;
import cn.zs.supply.common.core.web.UserSession;
import cn.zs.supply.common.utils.BeanValidators;

import javax.validation.Validation;
import javax.validation.Validator;

public class BaseService {
    /**
    protected Validator validator = Validation.buildDefaultValidatorFactory().getValidator();

    // 验证对象是否合法
    protected void validate(Object object, Class... groups) {
        BeanValidators.validateWithException(this.validator, object, groups);
    }
    **/

    /**
     * 获取当前登录用户
     *
     * @return

    protected LoginUserDto getCurrentUser() {
        LoginUserDto admin = new LoginUserDto();

        Object object;
        try {
            object = UserSession.get("loginUser");
        } catch (NullPointerException ex) {
            return admin;
        }
        if (object == null || (!(object instanceof LoginUserDto))) {
            return admin;
        }
        LoginUserDto user = (LoginUserDto) object;
        return user;
    }*/
}
